package practice.library.gremlin_scala.trial.tour.model

import gremlin.scala._
import org.joda.time.DateTime

import scala.util.{Failure, Success, Try}

/**
  * Created by lovepocky on 16/7/5.
  */
object vertex {

	object label {
		val city = "city"
		val sight = "sight"
		val hotel = "hotel"
		val shopping = "shopping"

	}

	def transform2CC(vertex: Vertex): Try[_] = {
		vertex.label() match {
			case label.city => Success(vertex.toCC[city])
			case label.sight => Success(vertex.toCC[sight])
			case label.hotel => Success(vertex.toCC[hotel])
			case label.shopping => Success(vertex.toCC[shopping])
			case _ => Failure(new Exception("label not match"))
		}
	}

	@label(label.city)
	case class city(name: String, name_chs: String, updateTime: DateTime = DateTime.now())

	@label(label.sight)
	case class sight(name: String, name_chs: String, updateTime: DateTime = DateTime.now())

	@label(label.hotel)
	case class hotel(name: String, name_chs: String, updateTime: DateTime = DateTime.now())

	@label(label.shopping)
	case class shopping(name: String, name_chs: String, updateTime: DateTime = DateTime.now())

}
